package org.hyl.javabase.集合扩展;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class sqlSet implements sql {
	HashSet<Object> al = new HashSet<>();
	String tablename;


	public sqlSet(String name) {
		tablename = name;
	}
	public Object get() {
		return al;
	}

	public void select(int i) {
		
		Iterator<Object> it = al.iterator();
		//if (al.isEmpty()) return;
		if (i < 0) return;
		int n = 0;
		while (it.hasNext()) {
			if (n == i) {
				System.out.println("row[" + i + "]=" + it.next());
				break;
			} else
				it.next();
			n++;
		}
	}

	public void selectall() {
		Iterator<Object> it = al.iterator();
		int i = 0;
		while (it.hasNext()) {
			System.out.println("row[" + i + "]=" + it.next());
			i++;
		}
	}

	public boolean find(Object o) {
		return al.contains(o);
	}

	public void insert(Object o) {
		al.add(o);	
		// 添加元素
		// c.add("孙悟空");
		// 虽然集合里不能放基本类型的值，但Java支持自动装箱
		// c.add(6);
	}

	public void update(int i, Object o) {
		al.remove(i);
		al.add(o);
	}

	public void delete(int i) {
		//有bug
		al.remove(i);
	}

	public void clear() {
		al.clear();
	}
	 public int size(){
		 return al.size();
	 }
}
